﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;


namespace WebApplication1
{
    
    public partial class WebForm2 : System.Web.UI.Page
    {
        private sqlHerper SqlHerper = new sqlHerper();

        protected void Page_Load(object sender, EventArgs e)
        {
            string name = TextBox1.Text;
            string pwd = TextBox2.Text;
            string email = TextBox3.Text;
            string constr = "server=.;uid=sa;pwd=123456;database=Student_db";
            SqlConnection con = new SqlConnection(constr);
            con.Open();
            string sql = "insert into StudentInfo (stu_name,password,email) values (@name,@pwd,@email) ";
            SqlParameter[] pars =
                {
                new SqlParameter("@name",name),
                new SqlParameter("@pwd",pwd),
                new SqlParameter("@email",email)
            };

             
            if (SqlHerper.Execute(sql, pars))
            {
                Literal1.Text = "注册成功！<a href='WebForm1.aspx'>去登录</a>";
            }
            else
            {
                Literal1.Text = "注册失败";
            }
          

        }
    }
}